/**
 * 播放器方法
 * @param playerId:顶层容器ID
 * @param vid:vid
 * @param stopTime：停止的时间
 * @param stopFn：停止执行的方法
 */
var txPlayerV2 = function (playerId, vid, stopTime, stopFn,onWriteFn, endFn) {
    var playTime = false;
    var isShare=false;
    //监听播放进度
    var _monitorPlayer = function (player) {
        if (typeof (stopFn) !== 'function') {
            stopFn = function () {
            };
        }
        playTime = setInterval(function () {
            var nowTime = player.getCurTime();
            if (nowTime >= stopTime) {
                if(!isShare){
                    stopFn();
                }
                //暂停
                player.pause(vid);
                isShare=true;
            }
        }, 1000);
    };
    var video = new tvp.VideoInfo();
    video.setVid(vid);
    var player = new tvp.Player("100%", 200);
    player.setCurVideo(video);
    player.create({
        width: "100%",
        height: 200,
        video: video,
        modId: playerId,
        wmode: "transparent",
        pic: tvp.common.getVideoSnapMobile(vid),
        autoplay: true,
        onwrite: function () {
            _monitorPlayer(player);
            onWriteFn(player);
        },
        onplay: function () {
        },
        onplaying: function () {
        },
        oninited: function () {

        },
        onended: function () {
            endFn();
        }
    });
    this.clearTime = function () {
        //创建播放器容器
        clearInterval(playTime);
    };
};